<!-- 合同-合同中心-合同档案库-解除合同 -->
<template>
  <ContentCard>
    <ConditionBox :margin-bottom="20" :margin-top="20">
      <template #left>
        <a-input-search
          :style="{ width: '220px' }"
          placeholder="合同名称/编号"
          search-button
          @search="onSearch"
          @press-enter="onSearch"
          v-model="nameSearch"
        />
      </template>
      <template #right>
        <a-button type="primary" @click="add(null)" style="margin-right: 10px"
          >发起合同签署</a-button
        >
        <a-button
          type="primary"
          @click="goDraftContract"
          style="margin-right: 10px"
          >发起起草合同</a-button
        >
        <a-button type="outline" @click="add(null)" style="margin-right: 10px"
          >导入</a-button
        >
        <a-button type="outline" @click="add(null)" style="margin-right: 10px"
          >导出</a-button
        >
      </template>
    </ConditionBox>

    <div class="wrap">
      <div class="left">
        <SiderType />
      </div>

      <div class="right">
        <table-turn
          style="height: 100%"
          :table-data="getTableData"
          ref="tableRef"
          :args="args"
        >
          <a-table-column :width="80">
            <template #title> 序号 </template>
            <template #cell="{ rowIndex }">
              {{ rowIndex + 1 }}
            </template>
          </a-table-column>
          <a-table-column :width="200" data-index="name" title="姓名">
          </a-table-column>
          <a-table-column :width="200" data-index="definition" title="公司">
          </a-table-column>
          <a-table-column :width="200" data-index="definition" title="入职部门">
          </a-table-column>
          <a-table-column :width="200" data-index="definition" title="职位">
          </a-table-column>
          <a-table-column :width="200" data-index="definition" title="工作性质">
          </a-table-column>
          <a-table-column :width="200" data-index="definition" title="员工状态">
          </a-table-column>
          <a-table-column :width="200" data-index="definition" title="入职时间">
          </a-table-column>
          <a-table-column :width="200" data-index="definition" title="签署状态">
          </a-table-column>
          <a-table-column :width="200" data-index="" title="操作" fixed="right">
            <template #cell="{ record }">
              <a-tooltip content="起草合同">
                <IconFont
                  type="icon-edit"
                  :size="26"
                  :style="{
                    marginRight: '10px',
                    cursor: 'pointer'
                  }"
                  @click="goEdit(record)"
                />
              </a-tooltip>
              <a-tooltip content="删除" position="left">
                <a-popconfirm
                  content="是否确认删除该条数据?"
                  @ok="del(record.id)"
                >
                  <icon-font
                    type="icon-delete"
                    :size="26"
                    :style="{
                      cursor: 'pointer',
                      marginRight: '10px'
                    }"
                  />
                </a-popconfirm>
              </a-tooltip>
            </template>
          </a-table-column>
        </table-turn>
      </div>
    </div>
  </ContentCard>
</template>

<script lang="ts" setup>
import SiderType from '../SiderType/index.vue';
const router = useRouter();
const title = '合同档案库';

const breadCrumb: string[] = ['合同', '合同中心', '合同档案库'];

// 表格配置
const args = {
  rowSelection: {
    type: 'checkbox',
    showCheckedAll: true,
    onlyCurrent: false
  }
};

let modalVisible = ref(false); // 判断新增弹出框是否打开
let currData = ref(); // 储存当前选中数据
let tableRef = ref();
let nameSearch = ref(''); // 搜索框值
let draftContractVisible = ref(false);

// 新增
const add = (record: any) => {
  modalVisible.value = true;
};

// 获取表格数据
const getTableData = async () => {
  try {
    // originData.value = await GetHumanChangeSetting({
    //   typeId: 1 // 人事异动默认传1
    // });
    // const res: any = originData.value.find(
    //   (item: any) => item.id === currId.value
    // );
    // res.content = res.personnelChange;
    // return Promise.resolve(res.personnelChange);
  } catch (error: unknown) {
    console.log(error);
  }
};

// 搜索框搜索事件
const onSearch = () => {
  refresh();
};

const goDraftContract = () => {
  router.push({
    name: 'ContractDraft'
  });
};

// 刷新表格数据
const refresh = () => {
  tableRef.value.loadData();
};
</script>

<style scoped lang="less">
.wrap {
  height: 100%;
  display: flex;

  .left {
  }
  .right {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
}

:deep(.arco-table .arco-spin) {
  height: calc(100% - 1px);
}
:deep(.arco-table-container) {
  height: 100%;
}
</style>
